package com.jiyun.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.domain.User;
import com.jiyun.admin.mapper.UserMapper;
import com.jiyun.admin.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spyx.common.result.Result;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author li
 * @since 2024-12-18
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {


    private final UserMapper userMapper;

    public UserServiceImpl(UserMapper userMapper){
        this.userMapper = userMapper;
    }

    @Override
    public Result login(User user) {

        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("user_id", user.getUserId());
        userQueryWrapper.eq("password",user.getPassword());
        User one = userMapper.selectOne(userQueryWrapper);
        if (one==null){
            return Result.fail();
        }

        return Result.ok(one);

    }
}
